<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<meta name="viewport"
	content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
<meta name="format-detection"
	content="telephone=no,email=no,date=no,address=no">
<title></title>
<link rel="stylesheet" type="text/css" href="../css/aui.css" />
<link rel="stylesheet" type="text/css"
	href="../css/aui-pull-refresh.css" />
<style type="text/css">
.aui-list .aui-list-item i.aui-iconfont {
	-webkit-align-self: center;
	align-self: center;
	font-size: 18px;
}
</style>
</head>
<body>
	<header class="aui-bar aui-bar-nav aui-bar-warning" id="aui-header">
	<a class="aui-pull-left" onclick="window.history.back(-1);"> <span
		class="aui-iconfont aui-icon-left"></span>
	</a>
	<div class="aui-title">合同信息</div>
	<a class="aui-pull-right"> </a> </header>

	<div class="aui-content aui-margin-b-15">
			<form id="myFrom" >
				<ul class="aui-list aui-form-list">
					<li class="aui-list-item">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-label">
								合同编号:
							</div>
							<div class="aui-list-item-input" id="contractNum"></div>
						</div>
					</li>
					<li class="aui-list-item">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-label">
								合同名称:
							</div>
							<div class="aui-list-item-input" id="contractName"></div>
						</div>
					</li>
					<li class="aui-list-item">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-label">
								所属客户:
							</div>
							<div class="aui-list-item-input" id="customerName"></div>
						</div>
					</li>
					<li class="aui-list-item">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-label">
								购买产品:
							</div>
							<div class="aui-list-item-input" id="productName"></div>
						</div>
					</li>
					<li class="aui-list-item">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-label">
								签约金额:
							</div>
							<div class="aui-list-item-input" id="transactionAmount"></div>
						</div>
					</li>
					<li class="aui-list-item">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-label">
								投资期限:
							</div>
							<div class="aui-list-item-input" id="investmentHorizon" > 
							</div>
						</div>
					</li>
					<li class="aui-list-item">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-label">
								开户银行:
							</div>
							<div class="aui-list-item-input" id="depositBank" > 
							</div>
						</div>
					</li>
					<li class="aui-list-item">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-label">
								银行账号:
							</div>
							<div class="aui-list-item-input" id="bankAccount" >
							</div>
						</div>
					</li>
					<li class="aui-list-item">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-label">
								签约时间:
							</div>
							<div class="aui-list-item-input" id="tradeDate"></div>
						</div>
					</li>
					<li class="aui-list-item">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-label">
								开始时间:
							</div>
							<div class="aui-list-item-input" id="startDate"></div>
						</div>
					</li>
					<li class="aui-list-item">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-label" >
								结束时间:
							</div>
							<div class="aui-list-item-input" id="endDate"></div>
						</div>
					</li>
				</ul>
			</form>
		</div>
	</body>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript">
	//初始方法
	$(function() {
		getPage();
	});

	//得到选择机会信息的id
	var id = "${param.id}";
		
	function getPage() {
		$.ajax({
					url : '${pageContext.request.contextPath}/appcrm/contractDetail.do?id=' +id,
					type : "POST",
					dataType : "json",
					success : function(data) {
						if (data.code == "0") {
							if (data.contract != null) {
								$("#contractNum").html(data.contract.contractNum);
								$("#contractName").html(data.contract.contractName);
								$("#customerName").html(data.contract.customer.customerName);
								$("#transactionAmount").html(formatCurrency(data.contract.transactionAmount));
								$("#productName").html(data.contract.productName);
								$("#bankAccount").html(data.contract.bankAccount);
								$("#depositBank").html(data.contract.depositBank);
								$("#investmentHorizon").html(data.contract.investmentHorizon);
								$("#tradeDate").html(toDate(data.contract.tradeDate));
								$("#startDate").html(toDate(data.contract.startDate));
								$("#endDate").html(toDate(data.contract.endDate));
							}else {
								alert('暂无数据！');
							}
						}
					}
				});
	}

	function toDate(data) {
		var date = new Date(data);
		var y = date.getFullYear();
		var m = date.getMonth() + 1;
		m = m < 10 ? '0' + m : m;
		var d = date.getDate();
		d = d < 10 ? ('0' + d) : d;
		return y + '-' + m + '-' + d;
		}
		
		/**
	 *转换金钱100,000.00 
	 */
	function formatCurrency(num) {
		if (num != null && num != "") {
			num = num.toString().replace(/\$|\,/g, '');
			if (isNaN(num))
				num = "0";
			sign = (num == (num = Math.abs(num)));
			num = Math.floor(num * 100 + 0.50000000001);
			cents = num % 100;
			num = Math.floor(num / 100).toString();
			if (cents < 10)
				cents = "0" + cents;
			for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++)
				num = num.substring(0, num.length - (4 * i + 3)) + ','
						+ num.substring(num.length - (4 * i + 3));
			return (((sign) ? '' : '-') + num + '.' + cents);
		}
	}

</script>
</html>